<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>class bind style</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<div>

    <div id="classStyle-2" v-bind:class="classObject"></div>
    <my-component id="componentStyle" v-bind:class="[isActive ? activeClass : '', errorClass]"></my-component>

</div>
<script>

    var classStyleVe = new Vue({
        el: '#classStyle',
        data: {
            isActive: true,
            error: null
        },
        computed: {
            classObject: function () {
                return {
                    active: this.isActive && !this.error,
                    'text-danger': this.error && this.error.type === 'fatal',
                }
            }
        }
    }

    var componentStyleVe = new Vue({
        el: '#componentStyle',
        data: {
            classObject: {
                isActive: true,
                'text-danger': false
            }
        }
    }

    Vue.component('my-component', {
        template: '<p class="foo bar">Hi</p>'
    })
</script>
</body>
</html>
